package jspeech.sample;

/**
 * 
 */

/**
 * @author Kenneth Lo
 *
 */

import java.io.IOException;

import jspeech.SpeechSpeaker;
import jspeech.exception.*;

/**
 * Sample code for {@link jspeech.SpeechSpeaker}. This sample using the
 * {@link jspeech.SpeechSpeaker} object to speak out the text. <br>
 * <br>
 * <p>
 * <li>1. Create SpeechSpeaker object.</li>
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>SpeechSpeaker speak = new SpeechSpeaker();</code>
 * <li>2. Start the SpeechSpeaker</li>
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>speak.start();</code>
 * <li>3. Send TTS command</li>
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>speak.TTS("Hello");</code>
 * <li>4. Close SpeechSpeaker object.</li>
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>speak.close();</code>
 * 
 * 
 * @author Kenneth Lo
 * 
 */
public class SpeechSpeakerDemo {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SpeechSpeaker speak = new SpeechSpeaker("JSpeech.xml");

		try {
			speak.start();
			speak.TTS("Hello! I am Mary!!");
			speak.TTS("Welcome to using Java Speech");
			speak.setVolume(50);
			speak.TTS("This is speaking in half volume");
			speak.setVolume(100);
			speak.setRate(2);
			speak.TTS("This is speaking in faster rate");
			speak.setRate(-2);
			speak.TTS("This is speaking in slower rate");
			speak.close();
		} catch (EngineNotFoundException e) {
			e.printStackTrace();
		} catch (EngineConnectionException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
